#!/bin/sh
# 把 git hooks 复制到 .git 目录中

if [[ ! -d "./.git" ]]; then
    echo "You should run this shell in Git Repo root directory"
    exit 1
fi

cd ./.git

if [ -d "hooks" ]; then
    if [ -d "hooks.bu"  ]; then
        rm -rf hooks
        echo "update git hooks..."
    else
        echo "back up your origin hooks to hook.bu"
        mv hooks hooks.bu
    fi
    ln -s ../git-hooks ./hooks
fi

exit 0
